import json


data = [
{"sid":"a1001","name":"zhangdasan","age": 21},
{"sid":"a1002","name":"lixianli","age": 20},
{"sid":"a1003","name":"zhaozhijian","age": 22},
]

f1 = open('test.json', 'w')
json.dump(data, f1)
print('成功写入数据到文件！\n')
f1.close()

f2 = open('test.json', encoding='utf-8')
line = f2.readline()
d = json.loads(line)
print(d)
for i in d:
    sid = i['sid']
    name = i['name']
    age = i['age']
    print(sid,name, age)
f2.close()

